package cevent.source.cloudcenter.server.service;/**
 * Created by Cevent on 2021/2/20.
 */

import cevent.source.cloudcenter.server.domain.SecondTable;
import cevent.source.cloudcenter.server.domain.SecondTableExample;
import cevent.source.cloudcenter.server.mapper.SecondTableMapper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author cevent
 * @description  自动生成generator
 * @date 2021/2/20 17:24
 */
@Service
public class SecondTableService {

    @Resource
    private SecondTableMapper secondTableMapper;

    public List<SecondTable> secondTables(){
        //倒序
        SecondTableExample secondTableExample=new SecondTableExample();
        secondTableExample.setOrderByClause("id desc");
        //调用自动生成的example查询列表，无条件查询(null)
        //return secondTableMapper.selectByExample(null);
        //有条件example查询
        return secondTableMapper.selectByExample(secondTableExample);
    }

    //1.根据id查询:selectByExample返回一个list，这里必须使用集合
    public List<SecondTable> secondTableById(){
        SecondTableExample secondTableExample=new SecondTableExample();
        secondTableExample.createCriteria().andIdEqualTo(2);
        return secondTableMapper.selectByExample(secondTableExample);
    }
}
